package folder.model.virtual;

import java.util.ArrayList;
import java.util.List;

import folder.model.link.Link;

public class VirtualNetwork
{	
	// Virtual network
	
	public static VirtualNetwork virtualNetwork( int identifier )
	{
		return new VirtualNetwork( identifier );
	}
	
	public VirtualNetwork( int identifier )
	{
		this.identifier = identifier;
	}
	
	private final int identifier;
	public int getIdentifier(){ return this.identifier; }
	
    public String toString(){ return identifier + ": " + virtualLinks; }
	
    // Virtual nodes
	
	private List< VirtualNode > virtualNodes = new ArrayList< VirtualNode >();
	public List< VirtualNode > getVirtualNodes(){ return this.virtualNodes; }
	public void setVirtualNodes( List< VirtualNode > virtualNodes ){ this.virtualNodes = virtualNodes; }
	public void addVirtualNode( VirtualNode virtualNode ){ this.virtualNodes.add( virtualNode ); }
	public VirtualNode getVirtualNode( int identifier ){ return virtualNodes.get( identifier ); }
	public int getNumberVirtualNodes(){ return this.virtualNodes.size(); }
	
	// Virtual links
	
	private List< VirtualLink > virtualLinks = new ArrayList< VirtualLink >();
	public List< VirtualLink > getVirtualLinks(){ return this.virtualLinks; }
	public void setVirtualLinks( List< VirtualLink > virtualLinks ){ this.virtualLinks = virtualLinks; }
	public void addVirtualLink( VirtualLink virtualLink ){ this.virtualLinks.add( virtualLink ); }
	public VirtualLink getVirtualLink( int identifier ){ return virtualLinks.get( identifier ); }
	public int getNumberVirtualLinks(){ return this.virtualLinks.size(); }
	
	public void release()
	{
		for( VirtualNode virtualNode: this.virtualNodes )
			virtualNode.release();
		
		for( VirtualLink virtualLink: this.virtualLinks )
			virtualLink.release();
	}
    
}
